import { defineStore } from 'pinia';
import {ref}from 'vue'

import { createPinia } from 'pinia'

const pinia = createPinia()

pinia.use(({ store }) => {
  store.$subscribe((mutation, state) => {
    // 进行持久化操作，例如保存 state 到本地存储
    localStorage.setItem('isLogin', JSON.stringify(state))
  })
})

export const useMyStore = defineStore({
  id: 'isLogin',
  state: () => {
    return {
      isLogin: false
    }
  },
  actions: {
    set() {
      this.isLogin = true
    },
    remove() {
      this.isLogin = false
    }
  },
})

export default pinia